import types from './mutation-types';
import lodashSet from 'lodash/set'
import lodashHas from 'lodash/has'

const mutations = {

    [types.TEST_STORE](state, payload) {
      console.log(state)
      console.log(payload)
    },
    [types.SET_STORE_DATA](state, payload) {
      console.log(state)
      console.log(payload)

        var path=[];
        var value="";
        if(!payload.path){
            path=Object.values(payload);
            value=path.pop();

        }else {
             path=payload.path;
             value=payload.value;
        }

        if(lodashHas(state, path)){
            lodashSet(state, path.join('.'), value);
        }
    },

};

export default mutations;
